<%@page import="com.grep.web.dto.TaskNumber"%>
<%@page import="com.grep.web.dto.SiteTaskDto"%>
<%@page import="com.grep.web.monitor.MonitorService"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.grep.web.IndexService,java.util.*"%> 
<%@ include file="../common/taglibs.jsp"%>
<%@ include file="../common/ckeckuser.jsp" %>
    <%
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
MonitorService monitorService = new MonitorService();
String taskId = request.getParameter("taskid");
String taskname = request.getParameter("taskname");
taskname = new String(taskname.getBytes("iso8859-1"), "UTF-8"); 
SiteTaskDto nowtask = null;

List<TaskNumber> taskNumbers = monitorService.getTaskNumbersById(taskId, 10);
request.setAttribute("nowtask",nowtask);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>采集监控</title>
<link href="${base }/style/style.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="${base }/style/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${base }/style/highcharts.js"></script>
<script type="text/javascript">
<% 
if(taskNumbers.size() >0){
	TaskNumber startNu = taskNumbers.get(taskNumbers.size()-1);
%>
$(function () {
    var chart;
    $(document).ready(function() {
        chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                zoomType: 'x',
                spacingRight: 20
            },
            title: {
                text: '<%=taskname %>任务监控'
            },
            subtitle: {
                text: null
            },
            xAxis: {
                type: 'datetime',
                maxZoom: 600000, // fourteen days
                title: {
                    text: '时间'
                }
            },
            yAxis: {
                title: {
                    text: '采集数量'
                },
                min: 1,
                startOnTick: false,
                showFirstLabel: false
            },
            tooltip: {
                
                formatter: function() {     //当鼠标悬置数据点时的格式化提示  
                    return '<b>'+ Highcharts.dateFormat('%Y-%m-%d %H:%M:%S' ,this.x) +'</b><br/>'+ this.series.name + ': '+ this.y;  
                }
            },
            legend: {
                enabled: false
            },
            plotOptions: {
                area: {
                    fillColor: {
                        linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1},
                        stops: [
                            [0, Highcharts.getOptions().colors[0]],
                            [1, 'rgba(2,0,0,0)']
                        ]
                    },
                    lineWidth: 1,
                    marker: {
                        enabled: false,
                        states: {
                            hover: {
                                enabled: true,
                                radius: 5
                            }
                        }
                    },
                    shadow: false,
                    states: {
                        hover: {
                            lineWidth: 1
                        }
                    }
                }
            },
    
            series: [{
                type: 'area',
                name: '条数',
                pointInterval: 600 * 1000,
                pointStart: Date.UTC(<%=(startNu.getTaskCollectDate().getYear()+1900) %> ,<%=startNu.getTaskCollectDate().getMonth() %>,
                <%=startNu.getTaskCollectDate().getDate() %>, <%=startNu.getTaskCollectDate().getHours() %>, <%=startNu.getTaskCollectDate().getMinutes() %>
                ),
                data: [
					<% 
					for(int i=taskNumbers.size()-1; i>=0; i--){
						out.print(taskNumbers.get(i).getTaskCollectNumber());
						if(i != 0){
							out.print(",");
						}
					}
					%>
                ]
            }]
        });
    });
    
});
<% } %>
</script>
</head>
<body>
<%@ include file="../common/header.jsp" %>  
<div id="sider_left">
			<img src="${base }/images/leftbordertop.jpg" class="imgfloat" />
			<div id="sl_cont" class="siderborder">
				<span id="sltitle">采集任务</span>
				<ul>
                   <li class="slwei">
                      <%=taskname %>
                   </li>
				</ul>
			</div>
			<img src="${base }/images/leftborderbuttom.jpg" class="imgfloat" />
		</div>
		<div id="sider_right">
			<img src="${base }/images/rightbordertop.jpg" class="imgfloat" />
			
			<div id="sr_cont" class="siderborder">
				<span style="color:#333; float:left; width:650px;"><%=taskname %>采集情况监控</span>
			 	<div id="container" style="width:650px; height:400px">
			 		<%
			 			if( taskNumbers.size() <=0){
			 				out.print("没有找到指定任务。");
			 			}
			 		%>
				</div>
			</div>
			
		</div>
</body>
</html>